package com.ruoyi.bussiness.controller;

import cn.hutool.json.JSONObject;
import com.ruoyi.common.core.api.ApiResult;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.service.business.SysSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设置Controller
 *
 * @author Song
 * @date 2024-10-29
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/common/setting")
@Api(tags = "设置")
public class SysSettingController extends BaseController {

    private final SysSettingService settingService;

    @ApiOperation("获取报单设置")
    @RequestMapping(value = "/getSetting",method = RequestMethod.GET)
    public ApiResult<JSONObject> getSetting(){
        JSONObject jsonObject= settingService.getSetting();
        return ApiResult.ok(jsonObject);
    }

    @ApiOperation("修改报单设置")
    @RequestMapping(value = "/saveSetting",method = RequestMethod.POST)
    public ApiResult<String> saveSetting(@RequestBody JSONObject jsonObject){
        settingService.saveSetting(jsonObject);
        return ApiResult.ok("修改成功");
    }
}
